<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Hello World | Raxan User Guide</title>
    <link href="../raxan/styles/master.css" rel="stylesheet" type="text/css" />
    <!--[if IE]><link rel="stylesheet" href="../raxan/styles/master.ie.css" type="text/css"><![endif]-->
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link href="highlight/styles/default.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="highlight/highlight.js"></script>
    <script type="text/javascript">
        hljs.initHighlightingOnLoad('javascript','html','php');
    </script>

</head>

<body>
    <div class="container c48 prepend-top">
        <h2 class="bottom">Raxan User Guide</h2>
        <div class="navbar">
            <div class="lf"><div class="rt"><div class="md">
                <ul>
                    <li><a href="../index.html" title="The Rich Ajax, CSS &amp; PHP Framework" >Home</a></li>
                    <li><a href="table-of-contents.html" title="Blog Posts" >Table Of Contents</a></li>
                </ul>
            </div></div></div>
        </div>
        <div class="prepend1 append1"><h2>A simple Hello World App</h2>

<p>Note: This tutorial assumes that you're already familiar with the basic php programming concepts. If you're new to php please visit http://www.php.net/getting-started to learn about the basics of the language.</p>

<p>To get started with PDI, we will explore what it takes to create a simple Hello World application.</p>

<p>To begin, simply create a file inside the root of your app folder called hello.php. For example: c:\website\app\hello.php</p>

<p>Next, we need to edit the page and include the raxan/pdi/gateway.php script.</p>

<pre><code>&lt;?php
include_once('raxan/pdi/gateway.php');
?&gt;
</code></pre>

<p>The pdi/gateway.php file will load all the necessary classes and functions that we will need to continue with our tutorial.</p>

<p>Create an instance of the RichWebPage class.</p>

<pre><code>$page = new RichWebPage();
</code></pre>

<p>Append the words "Hello World" to the body tag</p>

<pre><code>$page['body']-&gt;append('Hello World');
</code></pre>

<p>Finally, we need to send the reply to the client.</p>

<pre><code>$page-&gt;reply();
</code></pre>

<p>That's it! You can try running the script inside your browser to view the results.
Here's the complete code:</p>

<pre><code>&lt;?php
include_once('raxan/pdi/gateway.php');

$page = new RichWebPage();
$page['body']-&gt;append('Hello World');
$page-&gt;reply();

?&gt;
</code></pre>

<p>In addition to the above, we can use the globally accessible P() function to access the default Web Page Controller object.</p>

<pre><code>&lt;?php
    P('body')-&gt;append('Hello World');
    P()-&gt;page-&gt;reply();
?&gt;
</code></pre>
</div>
        <div class="tpb pad" style="text-align:right">
            <a href="table-of-contents.html" class="quiet">Back to Table of Content</a>
        </div>
    </div>
</body>

</html>

